local sk__zhengnan = fk.CreateSkill {

  name = "sk__zhengnan",

  tags = {},

}



sk__zhengnan:addEffect("active", {
  name = "sk__zhengnan",
  anim_type = "offensive",
  card_num = 0,
  target_num = 1,
  prompt = "#sk__zhengnan",
  can_use = function(self, player)
    return player:usedSkillTimes(sk__zhengnan.name, Player.HistoryPhase) == 0
  end,
  card_filter = Util.FalseFunc,
  target_filter = function(self, player, to_select, selected, selected_cards)
    return #selected == 0 and not to_select:prohibitUse(Fk:cloneCard("savage_assault"))
  end,
  on_use = function(self, room, effect)
    local player = effect.from
    local target = effect.tos[1]
    local card = Fk:cloneCard("savage_assault")
    card.skillName = sk__zhengnan.name
    local extra_data = {}
    extra_data.sk__zhengnan = { player.id, target.id }
    local use = {
      from = target,
      card = card,
      extra_data = extra_data,
    }
    room:useCard(use)
  end,
})

sk__zhengnan:addEffect(fk.Damage, {
  name = "#sk__zhengnan_delay",
  mute = true,
  can_trigger = function(self, event, target, player, data)
    if data.card and table.contains(data.card.skillNames, "sk__zhengnan") then
      local e = player.room.logic:getCurrentEvent():findParent(GameEvent.UseCard)
      if e then
        local use = e.data
        return use.extra_data and use.extra_data.sk__zhengnan and use.extra_data.sk__zhengnan[2] == player.id
      end
    end
  end,
  on_cost = Util.TrueFunc,
  on_use = function(self, event, target, player, data)
    local room = player.room
    local src
    local e = room.logic:getCurrentEvent():findParent(GameEvent.UseCard)
    if e then
      local use = e.data
      if use.extra_data and use.extra_data.sk__zhengnan and use.extra_data.sk__zhengnan[2] == player.id then
        src = room:getPlayerById(use.extra_data.sk__zhengnan[1])
      end
    end
    if src and not src.dead then
      src:drawCards(1, "sk__zhengnan")
    end
    if not player.dead then
      player:drawCards(1, "sk__zhengnan")
    end
  end,
})

return sk__zhengnan
